import pandas as pd
import numpy as np
df1 = pd.DataFrame(np.random.randint(0, 151,size=(42,2)),columns=['python','math'])
df2 = pd.DataFrame(np.random.randint(0, 151,size=(40,2)),columns=['python','math'])
# df = pd.concat([df1,df2])#行方向上的合并
# print(df.reset_index(drop=True))#数据清洗后设置索引
df = pd.concat([df1,df2],axis=1)#列方向上的合并
print(df.reset_index(drop=True))

#merge 根据共同的列进行数据融合
data1 = {
    'ID':[1,2,3],
    'Name':['Alice','Bob','Candy']
}
data2 = {
    'ID': [2, 3,4],
    'Age': [23,25,22]
}

df3 = pd.DataFrame(data1)
df4 = pd.DataFrame(data2)
print(pd.merge(df3,df4))


df5 = pd.DataFrame({'ID':[1,2,3],
'Name':['Tom','Amy','Jack'],
'subjects':['python','math','java'],
'scores':[76,93,89,]})

df5['age'] = [18,17,19]#直接赋值增加列
print(df1)
list1 = ['4班','3班','5班']#在指定索引位置增加列
df5.insert(1,'class',list1)
print(df5)